<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">


    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Teacher_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-teacher_title"  class="form-control"  type="text" value="{$row.teacher_title|htmlentities}">
            <input id="c-teacher_id"  class="form-control" name="row[teacher_id]" type="hidden" value="{$row.teacher_id|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Field_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-field_id" data-rule="required" data-source="resource/field/index" class="form-control selectpage" data-field="title" data-format-item="{title} - 费用：{price}" name="row[field_id]" type="text" value="{$row.field_id|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Prop_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-prop_id" data-rule="required" data-source="resource/prop/index" class="form-control selectpage" data-field="title" name="row[prop_id]" data-format-item="{title} - 费用：{price}" type="text" value="{$row.prop_id|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
        <div class="col-xs-12 col-sm-8">
                        
            <select  id="c-type" class="form-control selectpicker" name="row[type]">
                {foreach name="typeList" item="vo"}
                    <option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
                {/foreach}
            </select>

        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Unit_customer_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            <button id="c-unit_customer_title" type="button">选择单位</button>
            <!--<input id="c-unit_customer_title" data-rule="required"   class="form-control" type="text" value="">
            <input id="c-unit_customer_id" data-rule="required"  name="row[unit_customer_id]" class="form-control" type="hidden" value="">-->
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-title" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Business')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-business" class="form-control" name="row[business]" type="text" value="{$row.business|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Brief_introduction')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-brief_introduction" class="form-control " rows="5" name="row[brief_introduction]" cols="50">{$row.brief_introduction|htmlentities}</textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('City')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class='control-relative'><input id="c-city" class="form-control" data-toggle="city-picker" name="row[city]" type="text" value="{$row.city|htmlentities}"></div>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Address')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-address" class="form-control" name="row[address]" type="text" value="{$row.address|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-mobile" class="form-control" name="row[mobile]" type="text" value="{$row.mobile|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Nature')}:</label>
        <div class="col-xs-12 col-sm-8">
                        
            <select  id="c-nature" class="form-control selectpicker" name="row[nature]">
                {foreach name="natureList" item="vo"}
                    <option value="{$key}" {in name="key" value="$row.nature"}selected{/in}>{$vo}</option>
                {/foreach}
            </select>

        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Contacts')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-contacts" class="form-control" name="row[contacts]" type="text" value="{$row.contacts|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Sex_data')}:</label>
        <div class="col-xs-12 col-sm-8">
            
            <div class="radio">
            {foreach name="sexDataList" item="vo"}
            <label for="row[sex_data]-{$key}"><input id="row[sex_data]-{$key}" name="row[sex_data]" type="radio" value="{$key}" {in name="key" value="$row.sex_data"}checked{/in} /> {$vo}</label> 
            {/foreach}
            </div>

        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Department')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-department" class="form-control" name="row[department]" type="text" value="{$row.department|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Job_title')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-job_title" class="form-control" name="row[job_title]" type="text" value="{$row.job_title|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Mobild')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-mobild" class="form-control" name="row[mobild]" type="text" value="{$row.mobild|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Email')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-email" class="form-control" name="row[email]" type="text" value="{$row.email|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Birthday_time')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-birthday_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[birthday_time]" type="text" value="{$row.birthday_time}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">活动时间</label>
        <div class="col-xs-6 col-sm-2">
            <input id="c-activity_start_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[activity_start_time]" type="text" value="{$row.activity_start_time}">
        </div>
        <div class="col-xs-6 col-sm-2">
            <input id="c-activity_end_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[activity_end_time]" type="text" value="{$row.activity_end_time}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Activity_number')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-activity_number" class="form-control" name="row[activity_number]" type="number" value="{$row.activity_number|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Man_number')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-man_number" class="form-control" name="row[man_number]" type="number" value="{$row.man_number|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Woman_number')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-woman_number" class="form-control" name="row[woman_number]" type="number" value="{$row.woman_number|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Age_composition')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:build_checkboxs('row[age_composition][]', $ageList,$row['age_composition']);}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Participant')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:build_checkboxs('row[participant][]', $participantList,$row['participant']);}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Service_demand')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-service_demand" class="form-control" name="row[service_demand]" type="text" value="{$row.service_demand|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Channel')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group margin-bottom-sm">
                <input id="c-channel_type" class="form-control" name="row[channel]" placeholder="多个以逗号隔开" type="text" value="{$row.channel|htmlentities}">
                <span class="types input-group-addon" data-type="channel" data-search="获客渠道"><i class="fa fa-ellipsis-h"></i></span>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Activity_needs')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-activity_needs" class="form-control " rows="5" name="row[activity_needs]" cols="50">{$row.activity_needs|htmlentities}</textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Activity_goal')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:build_checkboxs('row[activity_goal][]', $activityGoalList,$row['activity_goal']);}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Activity_theme')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-activity_theme" class="form-control" name="row[activity_theme]" type="text" value="{$row.activity_theme|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Management')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-management" class="form-control" name="row[management]" type="text" value="{$row.management|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('User_remark')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-user_remark" class="form-control " rows="5" name="row[user_remark]" cols="50">{$row.user_remark|htmlentities}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Teacher_personnel')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-teacher_personnel" class="form-control " rows="5" name="row[teacher_personnel]" cols="50">{$row.teacher_personnel|htmlentities}</textarea>
        </div>
    </div>

    <input type="hidden" id="number" name="row[number]" value="{$row.number|htmlentities|default=0}">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Schedule')}:</label>
        <div class="col-xs-12 col-sm-8 dingjian">
            {present name="$row.schedule"}
                {volist name="$row.schedule" id="vo" }
                    <table   >
                        <tr>
                            <td>
                                <table class="table table-responsive fieldlist"  style="position:relative" data-template="testtpl" data-tag="tr">
                                    <tr>
                                        <td colspan="5">
                                            <div style="width:50px;height:50px;border:1px solid #009589;background-color: #009589;color:white;position:absolute;left:-66px;top:43px">
                                                <div style="text-align: center;margin-top: 8px">DAY</div>
                                                <div style="text-align: center">{$key}</div>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>时间</td>
                                        <td>内容安排</td>
                                        <td>地点</td>
                                        <td>备注</td>
                                        <td>操作</td>
                                    </tr>
                                    {volist name="$vo" id="vo1" key="k"}
                                    <tr>
                                        <td>
                                            <input  class=" datetimepicker" data-date-format="HH:mm" data-use-current="true" name="row[start_time_xc{$vo1.number}][]" size="5" type="text" value="{$vo1.start_time}">
                                            至
                                            <input  class=" datetimepicker" data-date-format="HH:mm" data-use-current="true" name="row[end_time_xc{$vo1.number}][]" size="5" type="text" value="{$vo1.end_time}">
                                        </td>
                                        <td>
                                            <input  class="form-control" name="row[content_xc{$vo1.number}][]" type="text" value="{$vo1.content}">
                                        </td>
                                        <td>
                                            <input  class="form-control" name="row[addr_xc{$vo1.number}][]" type="text" value="{$vo1.addr}">
                                        </td>
                                        <td>
                                            <input  class="form-control" name="row[remark_xc{$vo1.number}][]" type="text" value="{$vo1.remark}">
                                        </td>
                                        <td>
                                            <a href="javascript:;" class="btn btn-sm btn-success add1" ><i class="fa fa-plus"></i> 追加</a>
                                            {if condition="($vo1.number==1) and ($k==1) "}
                                            <span></span>
                                            {else /}
                                            &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" class="btn btn-sm btn-success " onclick="func4(this)"><i class="fa fa-minus"></i> 删除</a>
                                            {/if}
                                        </td>
                                    </tr>
                                    {/volist}
                                </table>
                            </td>
                        </tr>
                        <tr > <td colspan="5"><a href="javascript:;" class="btn btn-sm btn-success add2" ><i class="fa fa-plus"></i> 追加</a>
                            {if condition="$vo1.number>1 "}
                            &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" class="btn btn-sm btn-success " onclick="func3(this)"><i class="fa fa-minus"></i> 删除</a>
                            {else /}
                            <span2></span2>
                            {/if}
                            </td></tr>
                    </table>
                {/volist}
            {else /}

            {/present}


        </div>

    </div>
    <div class="form-group hidden">
        <label class="control-label col-xs-12 col-sm-2">{:__('Schedule')}:</label>
        <div class="col-xs-12 col-sm-8 moban">
            <table   >
                <tr>
                    <td>
                        <table class="table table-responsive fieldlist"  style="position:relative" data-template="testtpl" data-tag="tr">
                            <tr>
                                <td colspan="5">
                                    <div style="width:50px;height:50px;border:1px solid #009589;background-color: #009589;color:white;position:absolute;left:-66px;top:43px">
                                        <div style="text-align: center;margin-top: 8px">DAY</div>
                                        <div style="text-align: center">1</div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>时间</td>
                                <td>内容安排</td>
                                <td>地点</td>
                                <td>备注</td>
                                <td>操作</td>
                            </tr>
                            <tr>
                                <td>
                                    <input  class=" datetimepicker" data-date-format="HH:mm" data-use-current="true" name="row[start_time_mb1][]" size="5" type="text" value="{:date('H:i')}">
                                    至
                                    <input  class=" datetimepicker" data-date-format="HH:mm" data-use-current="true" name="row[end_time_mb1][]" size="5" type="text" value="{:date('H:i')}">
                                </td>
                                <td>
                                    <input  class="form-control" name="row[content_mb1][]" type="text">
                                </td>
                                <td>
                                    <input  class="form-control" name="row[addr_mb1][]" type="text">
                                </td>
                                <td>
                                    <input  class="form-control" name="row[remark_mb1][]" type="text">
                                </td>
                                <td>
                                    <a href="javascript:;" class="btn btn-sm btn-success add1" ><i class="fa fa-plus"></i> 追加</a>
                                    <span></span>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr > <td colspan="5"><a href="javascript:;" class="btn btn-sm btn-success add2" ><i class="fa fa-plus"></i> 追加</a><span2></span2></td></tr>
            </table>

        </div>

    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Price_person')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-price_person" class="form-control" name="row[price_person]" type="number" value="{$row.price_person|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Payment_cycle')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-payment_cycle" class="form-control" name="row[payment_cycle]" type="number" value="{$row.payment_cycle|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Prepayments')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-prepayments" class="form-control" step="0.01" name="row[prepayments]" type="number" value="{$row.prepayments|htmlentities}">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">费用报价:</label>
        <div class="col-xs-12 col-sm-8">
            <table class="table table-responsive fieldlist"   data-name="row[cost_quotation]" data-template="testtpl" data-tag="tr">
                <tr>
                    <td>费用说明</td>
                    <td>单价</td>
                    <td>数量</td>
                    <td>次数</td>
                    <td>小计</td>
                    <td></td>
                </tr>
                <tr>
                    <td style="text-align: right">
                        合计费用：
                    </td>
                    <td colspan="3" style="text-align: left">
                        <input id="total_fee" class="form-control" step="0.01" name="row[total_fee]" value="{$row.total_fee}" type="number" size="10">
                    </td>
                    <td style="text-align: left" colspan="2">
                        <button id="calculate_cost" type="button">计算费用</button>
                    </td>

                </tr>
                <tr>
                    <td colspan="5" style="text-align: center"><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> 增加费用</a></td>
                </tr>
                <textarea name="row[cost_quotation]" class="form-control hide" cols="30" rows="5">{$row.cost_quotation}</textarea>
            </table>
            <!--定义模板-->
            <script type="text/html" id="testtpl">
                <tr class="form-inline fee">
                    <td><input type="text" name="row[<%=name%>][<%=index%>][fee]" class="form-control" value="<%=row['fee']%>" size="30"></td>
                    <td><input type="number" step="0.01" name="row[<%=name%>][<%=index%>][unit_price]" class="form-control" value="<%=row['unit_price']%>" size="10"></td>
                    <td><input type="number" step="1" name="row[<%=name%>][<%=index%>][quantity]" class="form-control" value="<%=row['quantity']%>" size="10"></td>
                    <td><input type="number" step="1" name="row[<%=name%>][<%=index%>][frequency]" class="form-control" value="<%=row['frequency']%>" size="10"></td>
                    <td><input type="number" step="1" name="row[<%=name%>][<%=index%>][subtotal]" class="form-control" value="<%=row['subtotal']%>" size="10"></td>
                    <td><span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span></td>
                </tr>
            </script>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Payment_method')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::radios('row[payment_method]',  $paymentMethodList,$row['payment_method'],['data-rule'=>'required'])}
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Billing_type')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::radios('row[billing_type]',  $billingTypeList, $row['billing_type'],['data-rule'=>'required'])}
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
<script>


    function func(obj)
    {
        var that = $(obj);
        var html = that.parents('tr').prop('outerHTML');

        that.parent().parent().parent().append(html);

    }

    function func4(obj)
    {
        var that = $(obj);
        that.parent().parent().remove();
    }



    function func3(obj)
    {
        var that = $(obj);
        var number = $('#number').val();
        $('#number').val(number-1);
        that.parents('table').remove();
    }
</script>